/*
 * Copyright 2009-2010 the original author or authors.
 *
 * Licensed under the Apache license, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.internna.iwebjtracker.hudson.model;

import java.util.Map;
import java.util.List;

/**
 * Wraps all the interesting data retrieved from the configured Hudson job.
 *
 * @author Jose Noheda
 * @since 1.0
 */
public class LastBuildData {

    private int number;
    private String color, url;
    private List<Map.Entry<String, String>> messages;
    private boolean successful, unstable;

    /**
     * Health report messages.
     *
     * @return any
     */
    public List<Map.Entry<String, String>> getMessages() {
        return messages;
    }

    /**
     * Accessor method.
     *
     * @param messages any
     */
    public void setMessages(List<Map.Entry<String, String>> messages) {
        this.messages = messages;
    }

    /**
     * Yellow, blue, red...of the full build.
     *
     * @return any
     */
    public String getColor() {
        return color;
    }

    /**
     * Accessor method.
     *
     * @param color any
     */
    public void setColor(String color) {
        this.color = color;
    }

    /**
     * Number of this build.
     *
     * @return usually a positive integer
     */
    public int getNumber() {
        return number;
    }

    /**
     * Accessor method.
     *
     * @param number any
     */
    public void setNumber(int number) {
        this.number = number;
    }

    /**
     * Tells if the latest finished build was sucessful.
     *
     * @return any
     */
    public boolean isSuccessful() {
        return successful;
    }

    /**
     * Accessor method.
     *
     * @param successful any
     */
    public void setSuccessful(boolean successful) {
        this.successful = successful;
    }

    /**
     * A successful build can be unstable if some tests failed.
     *
     * @return any
     */
    public boolean isUnstable() {
        return unstable;
    }

    /**
     * Accessor method.
     *
     * @param unstable any
     */
    public void setUnstable(boolean unstable) {
        this.unstable = unstable;
    }

    /**
     * URL pointing to the build.
     *
     * @return a non empty string
     */
    public String getUrl() {
        return url + "/" + getNumber();
    }

    /**
     * Accessor method.
     *
     * @param url any
     */
    public void setUrl(String url) {
        this.url = url;
    }

}
